<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>用户列表</title>
    <link href="../css/bootstrap.min.css" rel="stylesheet">
    <link href="../css/materialdesignicons.min.css" rel="stylesheet">
    <link href="../css/style.min.css" rel="stylesheet">
    <link rel="stylesheet" href="css/reset.css">
    <link rel="stylesheet" href="css/index.css">
    <script src="js/jquery-3.3.1.js"></script>
    <script src="js/include.js"></script>
    <script>
        $(function () {
            load();
            $("#deletefavs").click(function () {
                if (confirm("确认取消收藏这些歌吗？")){
                    var mids;
                    if (true){
                        //1.添加判断状态
                        $.each($(".itemSelect"), function () {
                            if ($(this).is(':checked')){
                                confirm(1)
                                mids = $(this).val();
                                $.post("/music/favorite/deletefavs",{mids:mids},function () {
                                },"json");
                            }
                        });
                        location.href = "myfavorite.html";
                    }
                }
            });
        });



        function load(mid) {
            //1.根据cid加载路线列表数据
            $.post("/music/favorite/findByUid",
                {mid:mid},//动态值
                function (data) {
                    if (data[0].music.musicname!=null){
                        $navul = $("#navul");
                        //首页不变
                        var lis = '';
                        //拼接8个导航栏
                        for (var i = 0; i < data.length; i++) {
                            lis += '<tr>+<td>' +
                                '<label class="lyear-checkbox checkbox-primary">' +
                                '<input type="checkbox" name="uids" value="'+data[i].music.mid+'"' +
                                'id="'+data[i].music.mid+'" class="itemSelect"><span></span>' +
                                '</label>' +
                                '</td>' +
                                '<td>' + (i + 1) + '</td>' +
                                '<td>' + '<a href="musicInfo.html?mid='+data[i].music.mid+'">'+data[i].music.musicname+'</a>' + '</td>' +
                                '<td>' + data[i].singer.singername + '</td>' +
                                '<td>' +
                                '<div class="btn-group">' +
                                '<a class="btn btn-xs btn-default" title="删除" href="javascript:deletefav('+data[i].music.mid+');">删除</a>' +
                                '</div>' +
                                '</td>' + '</tr>';
                        }
                        lis += '</tbody>';
                        $navul.html(lis);
                    }else {
                        console.log("您还未登录！")
                    }
                },
                "json");
        }
        function deletefav(mid){
            if (confirm("确认取消收藏这首歌吗？")){
                $.post("/music/favorite/deletefav",{mid:mid},function (data){
                    location.href="myfavorite.html";
                });
            }
        }
    </script>
</head>
<body>
<div id="header">

</div>
<div class="lyear-layout-web">
    <div class="lyear-layout-container">
        <!--头部信息-->
        <!--End 头部信息-->
        <!-- 主题内容 -->
        <!--页面主要内容 table table-striped table-hover-->
        <div class="container-fluid">
            <div class="row">
                <div class="col-lg-12">
                    <div class="card">
                        <div class="card-toolbar clearfix">
                            <div class="toolbar-btn-action">
                                <a class="btn btn-danger" id="deletefavs"><i class="mdi mdi-window-close"></i>
                                    取消收藏</a>
                            </div>
                        </div>
                        <div class="card-body">
                            <form id="updateForm">
                                <div class="table-responsive">
                                    <table class="table table-bordered">
                                        <thead>
                                        <tr>
                                            <th>
                                                <label class="lyear-checkbox checkbox-primary">
                                                    <input type="checkbox" id="check-all"><span></span>
                                                </label>
                                            </th>
                                            <th>编号</th>
                                            <th>歌名</th>
                                            <th>歌手</th>
                                            <th>操作</th>
                                        </tr>
                                        </thead>
                                        <tbody  id="navul">
                                        </tbody>
                                    </table>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>

            </div>

        </div>
        <!--End 页面主要内容-->
    </div>
</div>
</body>
<script type="text/javascript" src="../js/jquery.min.js"></script>
<script type="text/javascript" src="../js/bootstrap.min.js"></script>
<script type="text/javascript" src="../js/perfect-scrollbar.min.js"></script>
<script type="text/javascript" src="../js/main.min.js"></script>
</html>
